{% extends "base.html" %}
{% import "bootstrap/wtf.html" as wtf %}
{% import "_macros.html" as macros %}
{% import "_my_wtf_macros.html" as my_wtf_macros %}

{% block title %}万屏时代OPC--虚拟号关系{% endblock %}

{% block panel_heading %}
  万屏时代OPC--虚拟号关系
    <div class="pull-right btn-group">
      <a href="{{ url_for('axb_bp.add_virtual_number') }}" class="btn btn-xs btn-success"
         style="margin-right: 5px;" target="_blank">
          新增虚拟号绑定
      </a>
  </div>
{% endblock %}

{% block panel_body %}

    <form id="search-virtual-number-form"
          action="{{ url_for('axb_bp.virtual_number_list') }}"
          method="post" class="form" role="form">
        {{ my_wtf_macros.form_field(form.tel_a, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.tel_b, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.tel_x, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.demand_id, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.valid, div_col=4, label_col=4, field_col=7) }}
        <div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
        {{ my_wtf_macros.form_field(form.created_at_begin, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.created_at_end, div_col=4, label_col=4, field_col=7) }}
        <div class="clearfix visible-xs-block visible-sm-block visible-md-block visible-lg-block"></div>
        {{ my_wtf_macros.form_field(form.updated_at_begin, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.updated_at_end, div_col=4, label_col=4, field_col=7) }}
        {{ my_wtf_macros.form_field(form.for_axb, div_col=4, label_col=4, field_col=7) }}
        <div class="btn-group pull-right">
            <span>
                <button type="submit" class="btn btn-info"
                        id="query-user-btn">
                查询
            </button>
            </span>
        </div>
    </form>

    {% if pagination %}
    <div class="pagination">
        {{ macros.pagination_widget(pagination, 'axb_bp.virtual_number_list', **url_kwargs) }}
    </div>
    {% endif %}

    <table id="cancel-attention-user-info-table" class="table table-bordered table-hover table-condensed table-striped">
        <thead>
            <tr>
                <th>用户ID</th>
                <th>项目ID</th>
                <th>号码A</th>
                <th>号码B</th>
                <th>虚拟号</th>
                <th>是否有效</th>
                <th>绑定时间</th>
                <th>最近使用时间</th>
                <th>解绑时间</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {% for i in items %}
            <tr>
                <td>{{ i.user_id }}</td>
                <td>{{ i.demand_id }}</td>
                <td>{{ i.tel_a }}</td>
                <td>{{ i.tel_b }}</td>
                <td>{{ i.tel_x }}</td>
                <td>{{ i.valid_display }}</td>
                <td>{{ i.created_datetime }}</td>
                <td>
                    {{ i.updated_datetime }}
                </td>
                <td>
                {# 仅当虚拟号关系失效时，将 updated_datetime 显示未解绑时间 #}
                {% if i.valid==0 %}
                    {{ i.updated_datetime }}
                {% endif %}
                </td>
                <td>
                    <a
                      class="btn btn-xs btn-primary"
                      href="{{url_for('axb_bp.virtual_number_info',id=i.id)}}"
                      name="virtual-number-info"
                      target="_blank"
                    >编辑</a><br>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>

    {% if pagination %}
    <div class="pagination">
        {{ macros.pagination_widget(pagination, 'axb_bp.virtual_number_list', **url_kwargs) }}
    </div>
    {% endif %}

{% endblock %}

{% block scripts %}
{{ super() }}
{% endblock %}

